export default {
  namespace: 'employee',

  state: [
    {
      key: '1',
      name: '张三',
      sex: '男',
    },
    {
      key: '2',
      name: '李四',
      sex: '女',
    },
  ],
  reducers: {
    deleteE(state, { payload }) {
      const { key: deleteKey } = payload;
      return state.filter((e) => e.key !== deleteKey);
    },

    updateEmployee(state, { payload }) {
      const { employee: newE } = payload;
      return state.map((e) => (e.key === newE.key ? newE : e));
    },

    createEmployee(state, { payload }) {
      const { employee: newEmployee } = payload;
      return state.concat([newEmployee]);
    },
  },
  // effects:{}
};
